package testJdk.commonUse.collections.lambda;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author keyer
 * @Description : 描述
 * Created by cyd on 2021-03-30 15:48:22
 */
public class Test01 {

    public static void main(String[] args) {
        List<Apple> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            Apple apple = new Apple();
            apple.setName("苹果" + i);
            apple.setWeight("重量" + i);
            apple.setColor("颜色" + i);
            list.add(apple);
        }
        //Map  appleList = new HashMap<String,Object>();
        //appleList.put("list",list);
        //ArrayList<Apple> list1 =(ArrayList<Apple>)appleList.get("list");
//        String str = list.stream().filter(n -> "苹果0".equals(n.getName()) || "苹果1".equals(n.getName())).
//                map(Apple::getName).
//                collect(Collectors.joining("_"));
//        System.out.println(str);

        // List<ExUserExam> in=list.stream().sorted(Comparator.comparing(ExUserExam ::getScore).reversed()).collect(Collectors.toList());
        List<Apple> apples = list.stream().sorted(Comparator.comparing(Apple::getName)).collect(Collectors.toList());
        System.out.println(apples);

    }

}
